using UnityEngine;

public class CharacterPunch : MonoBehaviour
{
	public AimHelper aimHelper;

	private CharacterFighting fighting;

	private CharacterInformation info;

	public float forceMultiplier = 1f;

	public bool isSetPunch;

	private void Awake()
	{
		fighting = GetComponentInParent<CharacterFighting>();
		info = GetComponentInParent<CharacterInformation>();
	}

	private void OnCollisionEnter(Collision collision)
	{
		if (collision.relativeVelocity.magnitude < 5f || (fighting.sincePunch > 0.2f && fighting.punchTime < 1f) || (fighting.punchTime > 1f && !fighting.isSwinging) || !isSetPunch)
		{
			return;
		}
		if (!collision.rigidbody)
		{
			fighting.stopHit = true;
			fighting.sincePunch = 0f;
		}
		else if (info.isAlive)
		{
			float num = 15f;
			Rigidbody rigidbody = collision.rigidbody;
			CharacterPart component = rigidbody.GetComponent<CharacterPart>();
			Vector3 force = num * forceMultiplier * aimHelper.Value * 75f;
			if (component != null)
			{
				component.TakeDamage(num, info, force);
			}
		}
	}
}
